package com.xncoding.easypoi.controller;


import com.xncoding.easypoi.model.District;
import com.xncoding.easypoi.util.MyCsvFileUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.*;

@RestController
public class FileController {

    private static final Logger _logger = LoggerFactory.getLogger(FileController.class);

    @RequestMapping("/createCsvFileJcTest")
    public void createCsvFileJcTest() {
        //类不确定 随便怎么传都行
        List<District> districts = null;//districtService.queryByParentCodes(Arrays.asList("110100"));
        //存放地址&文件名
        String fileName = "D:\\mycsv\\"+ MyCsvFileUtil.buildCsvFileFileName(districts);
        //创建表格行标题
        String tableNames = MyCsvFileUtil.buildCsvFileTableNames(districts);
        //创建文件
        MyCsvFileUtil.writeFile(fileName, tableNames);
        //写入数据
        String contentBody = MyCsvFileUtil.buildCsvFileBodyMap(districts);
        //调用方法生成
        MyCsvFileUtil.writeFile(fileName, contentBody);
    }

}
